package com.orkasgb.framework.echarts;

import com.github.abel533.echarts.Option;
import com.github.abel533.echarts.json.GsonUtil;

public class ExampleChartEchartsConvert extends AbstractChartEchartsConvert {

    public ExampleChartEchartsConvert() {
    }

    public static void example() {
        ExampleChartEchartsConvert example = new ExampleChartEchartsConvert();
        // 需要实现对应的接口方法convertChartOption()、convertJsonString()
        // filePath = example.convertFromOption();
        // filePath = example.convertFromJsonString();
        // example.convertFromOption();
        // example.convertFromJsonString();
        String filePath = example.convertFromScript();;
        System.out.println(filePath);
    }

    @Override
    public Option convertChartOption() {
        String json = "{\n" +
                "  tooltip: {\n" +
                "    trigger: 'item'\n" +
                "  },\n" +
                "  legend: {\n" +
                "    top: '5%',\n" +
                "    left: 'center'\n" +
                "  },\n" +
                "  series: [\n" +
                "    {\n" +
                "      name: 'Access From',\n" +
                "      type: 'pie',\n" +
                "      radius: ['40%', '70%'],\n" +
                "      avoidLabelOverlap: false,\n" +
                "      label: {\n" +
                "        show: false,\n" +
                "        position: 'center'\n" +
                "      },\n" +
                "      emphasis: {\n" +
                "        label: {\n" +
                "          show: true,\n" +
                "          fontSize: 40,\n" +
                "          fontWeight: 'bold'\n" +
                "        }\n" +
                "      },\n" +
                "      labelLine: {\n" +
                "        show: false\n" +
                "      },\n" +
                "      data: [\n" +
                "        { value: 1048, name: 'Search Engine' },\n" +
                "        { value: 735, name: 'Direct' },\n" +
                "        { value: 580, name: 'Email' },\n" +
                "        { value: 484, name: 'Union Ads' },\n" +
                "        { value: 300, name: 'Video Ads' }\n" +
                "      ]\n" +
                "    }\n" +
                "  ]\n" +
                "}";
        return GsonUtil.fromJSON(json);
    }

    /**
     * @return
     */
    @Override
    public String convertChartJsonString() {
        return "{\n" +
                "  tooltip: {\n" +
                "    trigger: 'item'\n" +
                "  },\n" +
                "  legend: {\n" +
                "    top: '5%',\n" +
                "    left: 'center'\n" +
                "  },\n" +
                "  series: [\n" +
                "    {\n" +
                "      name: 'Access From',\n" +
                "      type: 'pie',\n" +
                "      radius: ['40%', '70%'],\n" +
                "      avoidLabelOverlap: false,\n" +
                "      label: {\n" +
                "        show: false,\n" +
                "        position: 'center'\n" +
                "      },\n" +
                "      emphasis: {\n" +
                "        label: {\n" +
                "          show: true,\n" +
                "          fontSize: 40,\n" +
                "          fontWeight: 'bold'\n" +
                "        }\n" +
                "      },\n" +
                "      labelLine: {\n" +
                "        show: false\n" +
                "      },\n" +
                "      data: [\n" +
                "        { value: 1048, name: 'Search Engine' },\n" +
                "        { value: 735, name: 'Direct' },\n" +
                "        { value: 580, name: 'Email' },\n" +
                "        { value: 484, name: 'Union Ads' },\n" +
                "        { value: 300, name: 'Video Ads' }\n" +
                "      ]\n" +
                "    }\n" +
                "  ]\n" +
                "}";
    }


}
